<!--实时借记业务录入-->
<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="130px">
      <!--交易基础信息-->
      <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span>交易基础信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="业务类型" prop="bizTypeCode">
              <el-select v-model="form.bizTypeCode" placeholder="业务类型" @change="bizTypeCodeChange" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.BIZ_TYPE_131"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="业务种类" prop="bizCtgyCode">
              <el-select v-model="form.bizCtgyCode" placeholder="业务种类">
                <el-option
                  v-for="dict in busTypeList"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="记账标志" prop="cbflag">
              <el-select v-model="form.cbflag" clearable placeholder="业务种类" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.CBFLAG"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--收款人信息-->
      <el-card class="form-card payeeInfo-card">
        <div slot="header" class="label-header-msg">
          <span>收款人信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payee">
              <el-form-item label="收款人账号" prop="payeeActno">
                <el-input v-model="form.payeeActno" placeholder="收款人账号" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="4">
            <el-row>
              <el-button type="primary" icon="el-icon-search" plain @click="openPayeeDialog('payeeActno')">
                账号查找
              </el-button>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人名称" prop="payeeName">
              <el-input v-model="form.payeeName" placeholder="收款人名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="收款人地址" prop="payeeAddr">
              <el-input v-model="form.payeeAddr" placeholder="收款人地址" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="收款行行号" prop="payeeBrno">
                <el-input v-model="form.payeeBrno" placeholder="收款行行号" disabled />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款行行名" prop="payeeBrname" label-width="130px">
              <el-input v-model="form.payeeBrname" placeholder="收款行行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payee">
              <el-form-item label="收款人开户行行号" prop="payeeAccBrno">
                <el-input
                  v-model="form.payeeAccBrno"
                  placeholder="收款人开户行行号"
                  @keyup.enter.native="getBankInf('payeeAccBrno', form.payeeAccBrno)"
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-payee">
              <el-button type="primary" icon="el-icon-search" plain @click="openBankBranchDialog('payeeAccBrno')">
                行号查找
              </el-button>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人开户行行名" prop="payeeAccBrname" label-width="130px">
              <el-input v-model="form.payeeAccBrname" placeholder="收款人开户行行名" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--付款人信息-->
      <el-card class="form-card payerInfo-card">
        <div slot="header" class="label-header-msg">
          <span>付款人信息</span>
        </div>

        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="付款人账号" prop="payerActno">
              <el-input v-model="form.payerActno" placeholder="付款人账号" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-row>
              <el-button type="primary" icon="el-icon-search" plain @click="openPayerDialog('payerActno')">
                账号查找
              </el-button>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款人名称" prop="payerName">
              <el-input v-model="form.payerName" placeholder="付款人名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="付款人地址" prop="payerAddr">
              <el-input v-model="form.payerAddr" placeholder="付款人地址" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="付款行行号" prop="payerBrno">
              <el-input v-model="form.payerBrno" placeholder="" @keyup.enter.native="getBankInf('payerBrno',form.payerBrno)" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <div class="grid-payer">
              <el-button type="primary" icon="el-icon-search" plain @click="openBankBranchDialog('payerBrno')">
                行号查找
              </el-button>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款行行名" prop="payerBrname">
              <el-input v-model="form.payerBrname" placeholder="" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payer">
              <el-form-item label="付款人开户行行号" prop="payerAccBrno">
                <el-input
                  v-model="form.payerAccBrno"
                  placeholder="付款人开户机构号"
                  @keyup.enter.native="getBankInf('payerAccBrno', form.payerAccBrno)"
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-payer">
              <el-button type="primary" icon="el-icon-search" plain @click="openBankBranchDialog('payerAccBrno')">
                行号查找
              </el-button>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款人开户行行名" prop="payerAccBrname" label-width="130px">
              <el-input v-model="form.payerAccBrname" placeholder="付款人开户行行名" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--其他信息-->
      <el-card class="form-card payOtherInfo-card">
        <div slot="header" class="label-header-msg">
          <span>其他交易信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交易货币" prop="curcd">
              <el-input v-model="form.curcd" placeholder="交易货币" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="金额" prop="amount">
              <ht-amount-input
                v-model="form.amount"
                placeholder="金额"
              ></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="合同（协议）号" prop="protoId">
              <el-input
                v-model="form.protoId"
                placeholder="合同（协议）号"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <el-card class="form-card txnInfo-card" v-if="this.form.bizTypeCode === 'D203' || this.form.bizTypeCode ==='D204' || this.form.bizTypeCode ==='D205' || this.form.bizTypeCode ==='D206'">
        <div slot="header" class="label-header-msg">
          <span>实时通用票据截留业务附加数据</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出票日期：" prop="issueDate">
              <el-date-picker
                v-model="form.issueDate"
                type="date"
                value-format="yyyyMMdd"
                placeholder=""
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出票货币币种：" prop="issueCurcd">
              <el-input v-model="form.issueCurcd" placeholder=""  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出票金额：" prop="issueAmount">
              <el-input v-model="form.issueAmount" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="提示付款日期：" prop="payDate">
              <el-date-picker
                v-model="form.payDate"
                type="date"
                value-format="yyyyMMdd"
                placeholder=""
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="票据到期日期：" prop="draftMaturity">
              <el-date-picker
                v-model="form.draftMaturity"
                type="date"
                value-format="yyyyMMdd"
                placeholder=""
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="票据号码：" prop="noteNumber">
              <el-input v-model="form.noteNumber" placeholder=""  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付密码：" prop="payPassword">
              <el-input v-model="form.payPassword" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="票据密押：" prop="draftKey">
              <el-input v-model="form.draftKey" placeholder=""  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="承兑协议编号：" prop="protoNo">
              <el-input v-model="form.protoNo" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="承兑日期：" prop="acceptDate">
              <el-date-picker
                v-model="form.acceptDate"
                type="date"
                value-format="yyyyMMdd"
                placeholder=""
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="承兑人：" prop="acceptor">
              <el-input v-model="form.acceptor" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="申请人账号：" prop="applyAccount">
              <el-input v-model="form.applyAccount" placeholder=""  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人名称：" prop="applyName">
              <el-input v-model="form.applyName" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出票人账号：" prop="issueAccount">
              <el-input v-model="form.issueAccount" placeholder=""  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出票人全称：" prop="issueName">
              <el-input v-model="form.issueName" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交易合同号码：" prop="pactNumber">
              <el-input v-model="form.pactNumber" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="用途：" prop="use">
              <el-input v-model="form.use" placeholder="" type="textarea"  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="原收款人名称：" prop="oriPayeeName">
              <el-input v-model="form.oriPayeeName" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <el-card class="form-card txnInfo-card" v-if="this.form.bizTypeCode === 'D203' || this.form.bizTypeCode ==='D204' || this.form.bizTypeCode ==='D205' || this.form.bizTypeCode ==='D206'">
        <div slot="header" class="label-header-msg">
          <span>被背书人清单</span>
        </div>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="被背书人数" prop="endorserNumber">
              <el-input v-model="form.endorserNumber" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="被背书人名称" prop="endorserName">
              <el-input v-model="form.endorserName" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <div class="grid-payee">
              <el-button type="primary" icon="el-icon-search" plain @click="addListEndorser">添加</el-button>
            </div>
          </el-col>
        </el-row>

        <el-row type="flex">
          <ht-table
            ref="dataTableEndorser"
            :showSerialNumber="false"
            :multi-select="false"
            :tableBindColumns="tableBindColumnsEndorser"
            :showRightToolbar="false"
            :initData="false"
            :randomRowKey="true"
            :showPagination="false"
          >
            <template v-slot:operate>
              <el-table-column
                label="操作"
                align="left"
                width="120"
                fixed="right"
                class-name="small-padding fixed-width"
              >
                <template slot-scope="scope">
                  <ht-button-group
                    :buttonList="[
                        {
                          label: '删除',
                          doFunc: () => {
                            removeEndorser(scope.row, scope.$index);
                          },
                        },
                      ]"
                  />
                </template>
              </el-table-column>
            </template>
          </ht-table>
        </el-row>
        <el-row>
          <el-pagination
            background
            @size-change="handleSizeChangeEndorser"
            @current-change="handleCurrentChangeEndorser"
            :current-page="endorserCurPage"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="endorserPageSize"
            layout="->,total, sizes, prev, pager, next, jumper"
            :total="endorserList.length">
          </el-pagination>
        </el-row>
      </el-card>
      <el-card class="form-card txnInfo-card" v-if="this.form.bizTypeCode =='D102'">
        <div slot="header" class="label-header-msg">
          <span>通存业务附加数据域</span>
        </div>
<!--        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="交易方式" prop="busType">
              <el-select style="width: 100%;" v-model="form.busType" placeholder="交易方式">
                <el-option
                  v-for="dict in dictMap.BUS_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>-->
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="地域标识" prop="regionid">
              <el-input v-model="form.regionid" @change="getbase('RegionId')" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-input v-model="form.regionidDesc" :disabled="true" />
          </el-col>

          <el-col :span="6">
            <el-form-item label-width="20px">
              <el-button icon="el-icon-search" plain type="primary" @click="openBasedataDialog('RegionId')">
                请选择
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="磁介质类型：" prop="mediumType">
              <el-select v-model="form.mediumType" placeholder=""  style="width: 100%">
                <el-option
                  v-for="dict in dictMap.Medium_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="磁道信息数目：" prop="mediumNum">
              <el-input v-model="form.mediumNum" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-otherInfo">
              <el-form-item label="磁道信息1：" prop="mediumInfo1">
                <el-input type="textarea" v-model="form.mediumInfo1" placeholder=""  />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-otherInfo">
              <el-form-item label="磁道信息2：" prop="mediumInfo2">
                <el-input type="textarea" v-model="form.mediumInfo2" placeholder=""  />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-otherInfo">
              <el-form-item label="磁道信息3：" prop="mediumInfo3">
                <el-input type="textarea" v-model="form.mediumInfo3" placeholder=""  />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="卡序号：" prop="cardNum">
              <el-input v-model="form.cardNum" placeholder="" maxlength="3" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="IC卡信息：" prop="cardInfo">
              <el-input v-model="form.cardInfo" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="证件类型：" prop="idType">
              <el-select v-model="form.idType" placeholder=""  style="width: 100%">
                <el-option
                  v-for="dict in dictMap.Id_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="证件号码：" prop="idNum">
              <el-input v-model="form.idNum" placeholder=""  />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm" :loading="isLoading">提交</el-button>
      <el-button type="warning" @click="refresh" :loading="isLoading">重置</el-button>
    </div>
    <bank-branch-dialog ref="bankBranchDialog" @confirm="confirmBankBranch"></bank-branch-dialog>
    <base-data-dialog ref="basedataDialog" @confirm="confirmData"></base-data-dialog>
    <payee-dialog ref="payeeDialog" @confirm="confirmPayee"></payee-dialog>
    <payer-dialog ref="payerDialog" @confirm="confirmPayer"></payer-dialog>
  </div>
</template>

<script>
import { submit, query } from "@/api/cnaps/bepsDraft/realtime_debits_operations_entry.js";
import { listPageMixin } from "@/libs/listPageMixin";
import BankBranchDialog from "@/views/components/BankBranchDialog";
import { mapGetters } from "vuex";
import HtAmountInput from "@/views/components/HtAmountInput";
import BaseDataDialog from "@/views/components/BasedataDialog";
import { getBasedata } from "@/api/cnaps/common/basedata";
import { getBankInfByBankCode } from "@/api/cnaps/common/bankInfo";
import PayeeDialog from "@/views/components/PayeeDialog/index.vue";
import PayerDialog from "@/views/components/PayerDialog/index.vue";
export default {
  name: "InsideTransferEntry",
  mixins: [listPageMixin],
  components: {PayerDialog, PayeeDialog, BaseDataDialog, HtAmountInput, BankBranchDialog },
  computed: {
    ...mapGetters(["name", "globalBusData"]),
  },
  data() {
    return {
      queryData: {},
      isLoading: false,
      busTypeList: [],
      endorserList:[],
      endorserCurPage:1,
      endorserPageSize: 20,
      //背书表格
      tableBindColumnsEndorser: [{ prop: "endorserName", label: "被背书人名称" }],

      // 录入参数
      form: {
        bizTypeCode: "D100",
        bizCtgyCode: "",
        cbflag: "",
        payerBrno: "",
        payerBrname: "",
        payerActno: "",
        payerName: "",
        payerAddr: "",
        payerAccBrno: "",
        payerAccBrname: "",
        payeeActno: "",
        payeeName: "",
        payeeAddr: "",
        payeeBrno: "",
        payeeBrname: "",
        payeeAccBrno: "",
        payeeAccBrname: "",
        curcd: "CNY",
        amount: "",
        protoId: "",
        listEndorser:[],
      },
      rules: {
        bizTypeCode: [{ required: true, message: "不能为空", trigger: "change" }],
        bizCtgyCode: [{ required: true, message: "不能为空", trigger: "change" }],
        cbflag: [{ required: true, message: "不能为空", trigger: "change" }],
        payerBrno: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payerAccBrno: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payeeActno: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payerActno: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payerName: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payeeName: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payeeBrno: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        payeeAccBrno: [{ required: true, message: "不能为空", trigger: ['blur', 'change'] }],
        amount: [{ required: true, message: "不能为空", trigger: "blur" }],
        protoId: [{ required: true, message: "不能为空", trigger: "blur" }],
      },
      searchFormDictList: ["BIZ_TYPE_131", "CBFLAG", "BIZ_CTGY_BEPS_A101","BUS_TYPE","Medium_Type_Code",
        "Id_Type_Code"],
    };
  },
  created() {
    query().then((res) => {
      this.$set(this.form, "payeeBrno", res.result.payeeBrno);
      this.$set(this.form, "payeeBrname", res.result.payeeBrname);

      this.queryData = res.result;
    });
  },
  mounted() {
    this.bizTypeCodeChange(this.form.bizTypeCode);
  },

  methods: {
    //切换每页显示数据量时的回调
    handleSizeChangeEndorser (size) {
      this.endorserPageSize = size;
      this.handleCurrentChangeEndorser(this.endorserCurPage);
    },
    //切换页码回调
    handleCurrentChangeEndorser(currentPage) {
      let page = this.endorserList.slice((currentPage-1)*this.endorserPageSize,currentPage*this.endorserPageSize);
      this.$refs.dataTableEndorser.dataList = page
      this.endorserCurPage = currentPage;
    },

    // 收款人账号查找
    openPayeeDialog(fromFlag = "") {
      this.$refs.payeeDialog.show(fromFlag);
    },
    confirmPayee(fromFlag, row) {
      if (fromFlag == "payeeActno") {
        this.$set(this.form, "payeeActno", row.actNo);
        this.$set(this.form, "payeeName", row.name);
        this.$set(this.form, "payeeBrno", row.rcvBrno);
        this.$set(this.form, "payeeBrName", row.rcvBrname);
        this.$set(this.form, "payeeAddr", row.addr);
        this.$set(this.form, "payeeAccBrno", row.accBrno);
        this.$set(this.form, "payeeAccBrName", row.accBrnoName);
      }
    },
    // 付款人账号查找
    openPayerDialog(fromFlag = "") {
      this.$refs.payerDialog.show(fromFlag);
    },
    confirmPayer(fromFlag, row) {
      if (fromFlag == "payerActno") {
        this.$set(this.form, "payerActno", row.actNo);
        this.$set(this.form, "payerName", row.name);
        this.$set(this.form, "payerAddr", row.addr);
      }
    },
    bizTypeCodeChange(code) {
      //联动修改bizCtgyCode
      let dictKeyPre = `BIZ_CTGY_BEPS_${code}`;
      this.getDicts(dictKeyPre).then((response) => {
        this.busTypeList = response.result;
        this.$set(this.form, "bizCtgyCode", this.busTypeList[0].value);
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.loading = true;
          if(this.form.bizTypeCode === 'D203' || this.form.bizTypeCode ==='D204' || this.form.bizTypeCode ==='D205' || this.form.bizTypeCode ==='D206'){
            this.$set(this.form,"listEndorser",this.endorserList)
          }
          submit(this.form)
            .then((res) => {
              this.msgSuccess("录入成功");
              this.$alert(`CORE_ID: ${res.result.rspId}`, "生成交易流水号", {
                confirmButtonText: "确定",
                callback: (action) => {
                },
              });
              this.loading = false;
            })
            .catch((err) => {
              this.loading = false;
            });
        }
      });
    },
    //点击重置按钮
    refresh() {
      this.resetForm("form");
      this.bizTypeCodeChange(this.form.bizTypeCode);
      this.$set(this.form, "payeeBrno", this.queryData.payeeBrno);
      this.$set(this.form, "payeeBrname", this.queryData.payeeBrname);
    },

    //行名行号返回
    confirmBankBranch(fromFlag, row) {
      if (fromFlag == "payerBrno") {
        this.$set(this.form, "payerBrno", row.bankCode);
        this.$set(this.form, "payerBrname", row.orgFullname);
      } else if (fromFlag == "payeeAccBrno") {
        this.$set(this.form, "payeeAccBrno", row.bankCode);
        this.$set(this.form, "payeeAccBrname", row.orgFullname);
      } else if (fromFlag == "payerAccBrno") {
        this.$set(this.form, "payerAccBrno", row.bankCode);
        this.$set(this.form, "payerAccBrname", row.orgFullname);
      }
    },
    getBankInf(searchType, bankCode) {
      getBankInfByBankCode(bankCode).then((response) => {
        if (response.code == "S" && (response.result !== null&&response.result !== undefined)) {
          switch (searchType) {
            case "payerBrno":
              this.$set(this.form, "payerBrno", response.result.bankCode);
              this.$set(this.form, "payerBrname", response.result.orgFullname);
              break;
            case "payerAccBrno":
              this.$set(this.form, "payerAccBrno", response.result.bankCode);
              this.$set(this.form, "payerAccBrname", response.result.orgFullname);
              break;
            case "payeeBrno":
              this.$set(this.form, "payeeBrno", response.result.bankCode);
              this.$set(this.form, "payeeBrname", response.result.orgFullname);
              break;
            case "payeeAccBrno":
              this.$set(this.form, "payeeAccBrno", response.result.bankCode);
              this.$set(this.form, "payeeAccBrname", response.result.orgFullname);
              break;
          }
        } else {
          this.msgSuccess("查无此行号");
          switch (searchType) {
            case "payerBrno":
              this.$set(this.form, "payerBrname", null);
              break;
            case "payerAccBrno":
              this.$set(this.form, "payerAccBrname", null);
              break;
            case "payeeBrno":
              this.$set(this.form, "payeeBrname", null);
              break;
            case "payeeAccBrno":
              this.$set(this.form, "payeeAccBrname", null);
              break;
          }
        }
      });
    },
    //行名行号查询
    openBankBranchDialog(fromFlag = "") {
      this.$refs.bankBranchDialog.show(fromFlag);
    },

    //回车获取basedata值
    getbase(dataType) {
      const dataValue = this.form.regionid;
      if (dataValue === "" || dataValue === null || dataValue === undefined) {
        return;
      }

      getBasedata(dataType, dataValue)
        .then((response) => {
          if (response.code == "S" && response.result !== null) {
            this.$set(this.form, "regionid", response.result.dataValue);
            this.$set(this.form, "regionidDesc", response.result.dataDesc);
          } else {
            this.msgSuccess("找不到对应的字典项");
            this.$set(this.form, "regionid", null);
            this.$set(this.form, "regionidDesc", null);
          }
        })
        .catch((err) => {
          this.$set(this.form, "regionid", null);
          this.$set(this.form, "regionidDesc", null);
        });
    },
    openBasedataDialog(dataType = "") {
      this.$refs.basedataDialog.show(dataType);
    },
    confirmData(fromFlag, row) {
      this.$set(this.form, "regionid", row.dataValue);
      this.$set(this.form, "regionidDesc", row.dataDesc);
    },


    //背书表格
    addListEndorser() {
      let endorserName = this.form.endorserName;
      if (endorserName === "" || endorserName === undefined) {
        this.msgError("请输入被背书人名称");
      } else {
        this.$refs.dataTableEndorser.dataList.push({endorserName: this.form.endorserName});
        this.endorserList.push({endorserName: this.form.endorserName})
        this.$set(this.form, "endorserNumber", this.endorserList.length);
        this.$set(this.form, "listEndorser", this.$refs.dataTableEndorser.dataList);
        this.$set(this.form, "endorserName", "");
        this.handleCurrentChangeEndorser(this.endorserCurPage);
      }
    },
    //删除背书表格
    removeEndorser(row, index) {
      let delIndex = (this.endorserCurPage-1) * this.endorserPageSize + index;
      this.endorserList.splice(delIndex, 1);
      this.$refs.dataTableEndorser.dataList = this.endorserList
      if(index === 0 && this.endorserCurPage !== 1){
        this.handleCurrentChangeEndorser(this.endorserCurPage-1);
      }else {
        this.handleCurrentChangeEndorser(this.endorserCurPage);
      }
      this.$set(this.form, "listEndorser", this.$refs.dataTableEndorser.dataList);
      this.$set(this.form, "endorserNumber", this.endorserList.length);
    },

  },
};
</script>
<style>
.app-container {
  overflow: scroll;
}
.dialog-footer {
  margin: 10px 0;
  text-align: center;
}
</style>
